<template>
  <div class="main">
    <div class="main-top flex-between flex-align-items-center">
      <p class="font-16-B">全部消息</p>
      <div class="flex flex-align-items-center">
        <i class="iconfont icon-yidu"></i>
        <span class="font-14">全部已读</span>
      </div>
    </div>
    <div class="list">
      <div v-for="item in list" :key="item.id" class="item flex-between flex-align-items-center pointer"
        @click="openNoticeDetail(item)">
        <div class="item-left">
          <div class="item-name flex flex-align-items-center">
            <p class="font-14 flex flex-align-items-center" :class="{ read: item.isRead }">{{ item.isRead ? '已读' : '未读' }}
            </p>
            <h3 class="font-14">· {{ item.name }}</h3>
          </div>
          <p class="item-desc font-12 ellipsis-1">{{ item.content }}</p>
        </div>
        <div class="item-right flex flex-align-items-center">
          <p class="item-type font-12">{{ item.type }}</p>
          <p class="item-time font-12">{{ item.time }}</p>
        </div>
      </div>
    </div>
    <div class="pagination flex-center">
      <el-pagination :page-sizes="[10, 20, 50, 100]" layout="prev, pager, next, total" :total="total" />
    </div>
  </div>

  <notice-detail v-if="noticeDetail.show" :id="noticeDetail.id" @close="noticeDetail.show = false"></notice-detail>
</template>

<script setup>
import NoticeDetail from '@/components/noticeDetail.vue';
import { ref } from 'vue';

const total = ref(100);
const list = ref([
  {
    id: 1,
    name: '标题',
    content: '内容内容内容内容内容内容内容内容内容内容内容内容',
    time: '2023-12-11',
    type: '消息通知',
    isRead: false
  },
  {
    id: 2,
    name: '标题',
    content: '内容内容内容内容内容内容内容内容内容内容内容内容',
    time: '2023-12-11',
    type: '消息通知',
    isRead: true
  }
]);
const noticeDetail = ref({
  show: false,
  id: null
});

// 打开通知详情
const openNoticeDetail = item => {
  noticeDetail.value = {
    show: true,
    id: item.id
  }
}
</script>

<style lang="less" scoped>
.main {
  margin: 24px 32px 32px;
  padding: 24px 32px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .04);

  .main-top {
    margin-bottom: 32px;

    p {
      color: @main-color;
      line-height: 22px;
      padding-bottom: 8px;
      border-bottom: 2px solid @main-color;
    }

    div {
      i {
        color: @main-color;
        margin-right: 8px;
      }

      span {
        color: @main-color;
      }
    }
  }

  .list {
    margin-bottom: 24px;

    .item {
      height: 101px;
      padding: 24px 40px 24px 16px;
      background: rgba(235, 237, 240, .2);
      border-radius: 4px;
      border-bottom: 1px solid #ebedf0;

      .item-name {
        margin-bottom: 8px;

        p {
          color: @main-color;
          position: relative;
          margin-right: 8px;

          &::before {
            content: "";
            width: 4px;
            height: 4px;
            background: @main-color;
            border-radius: 50%;
            margin-right: 10px;
          }

          &.read {
            color: #999;

            &::before {
              background: #999;
            }
          }
        }

        h3 {
          color: #333;
        }
      }

      .item-desc {
        color: #999;
        padding-left: 14px;
      }

      .item-type {
        width: 72px;
        height: 22px;
        background: #f5f6f5;
        border-radius: 11px;
        color: #333;
        text-align: center;
        line-height: 22px;
        margin-right: 24px;
      }

      .item-time {
        color: #999;
      }
    }
  }
}
</style>
